home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / oper_sys / presto / prest1_0.lha / Tests / exer / atomtest.C next >
C/C++ Source or Header  |  1991-12-11  |  1KB  |  74 lines

  1.  
  2. //
  3. // Tests atomic integers.
  4. //
  5.  
  6.  
  7. #include <stream.h>
  8. #include "presto.h"
  9. #include "atomic_int.h"
  10.  
  11. AtomicInt counter(0);
  12. static shared_t loopcount = 150;
  13.  
  14. int
  15. Main::init()
  16. {
  17.     nummainthreads = 1;
  18.     for (argc--, argv++; *argv && **argv == '-'; argv++, argc--)
  19.         switch (*(*argv + 1)) {
  20. #ifdef sequent
  21. #ifdef i386
  22.                 case 'a':
  23.                         affinity = 1;
  24.                 break;
  25. #endif /* i386 */
  26. #endif /* sequent */
  27.             case 'q':
  28.                 quantum = atoi(*argv + 2);
  29.                 break;
  30.             case 'n':
  31.                 numprocessors = atoi(*argv + 2);
  32.                 break;
  33.             case 't':
  34.                 nummainthreads = atoi(*argv + 2);
  35.                 break;
  36.             case 'l':
  37.                 loopcount = atoi(*argv + 2);
  38.                 break;
  39.             default:
  40.                 cerr << chr(*(*argv + 1)) << " unknown flag.\n";
  41.                     return -1;
  42.         }
  43.     return 0;
  44. }
  45.     
  46. int
  47. Main::main()
  48. {
  49.     int i;
  50.  
  51.     for(i = 0; i < loopcount; i++) {
  52. //        counter += 2;
  53. //        counter = counter - 2;
  54. //        counter -= 2;
  55. //        counter = counter + 2;
  56.         counter++;
  57.         counter--;
  58.     }
  59. }
  60.  
  61. int
  62. Main::done()
  63. {
  64.     if (counter == 0)
  65.         cout << "Success.\n";
  66.     else
  67.         cout << "Failure.\n";
  68.     return 0;
  69. }
  70.  
  71.  
  72.  
  73.  
  74.